package com.java.wechat.config;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.github.tobato.fastdfs.FdfsClientConfig;
import com.java.wechat.util.SpringUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.Import;
import org.springframework.jmx.support.RegistrationPolicy;

/**
 * @author jiangli
 * @date 2019/11/1 20:44
 */
@Configuration
@Import(FdfsClientConfig.class)  //导入FastDFS-Client组件
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)  // 解决jmx重复注册bean的问题
public class RConfig {

    /**
     * 唯一ID生成器
     */
    @Bean
    public Snowflake snowflake() {
        return IdUtil.createSnowflake(1, 1);
    }

	/**
	 * 提供手动获取被spring管理的bean对象
	 */
	@Bean
    public SpringUtil springUtil() {
        return new SpringUtil();
    }
}
